{{ if and .Site.Params.enablePostShare (.Params.share | default .Site.Params.displayPostShare) }}

    {{- partial "utils/summary.html" . -}}
    {{- $description := .Description | default (.Scratch.Get "summary") | default .Site.Params.siteDescription | plainify -}}

    {{- partial "utils/images.html" . -}}
    {{- $images := .Scratch.Get "images" -}}
    {{- $images := .Scratch.Add "images" (slice (.Site.Params.siteLogo | absURL)) -}}
    {{- $images := (index (.Scratch.Get "images") 0) -}}

    <div class="post-share">

        {{ if .Site.Params.displayShareOnText }}
            <div class="share-text">{{ i18n "shareOn" }}</div>
        {{ end }}

        <div class="share-items">

            {{ if .Site.Params.shareOnTwitter }}
                {{ $icon := (replace .Site.Data.SVG.twitter "icon" "icon twitter-icon") }}
                <div class="share-item twitter">
                    {{ $url := (printf `https://twitter.com/share?url=%s&text=%s&via=%s` .Permalink .Title .Site.Params.siteTwitter) }}
                    <a href="{{ $url | safeURL }}" title="{{ i18n "shareOnTitle" }}{{ i18n "twitter" }}" target="_blank" rel="noopener">
                        {{- $icon | safeHTML -}}
                    </a>
                </div>
            {{ end }}

            {{ if .Site.Params.shareOnFacebook }}
                {{ $icon := (replace .Site.Data.SVG.facebook "icon" "icon facebook-icon") }}
                <div class="share-item facebook">
                    {{ $url := (printf `https://www.facebook.com/sharer/sharer.php?u=%s` .Permalink) }}
                    <a href="{{ $url | safeURL }}" title="{{ i18n "shareOnTitle" }}{{ i18n "facebook" }}" target="_blank" rel="noopener">
                        {{- $icon | safeHTML -}}
                    </a>
                </div>
            {{ end }}

            {{ if .Site.Params.shareOnLinkedIn }}
                {{ $icon := (replace .Site.Data.SVG.linkedin "icon" "icon linkedin-icon") }}
                <div class="share-item linkedin">
                    {{ $url := (printf `https://www.linkedin.com/shareArticle?mini=true&url=%s&title=%s&summary=%s&source=%s` .Permalink .Title $description .Site.Title) }}
                    <a href="{{ $url | safeURL }}" title="{{ i18n "shareOnTitle" }}{{ i18n "linkedin" }}" target="_blank" rel="noopener">
                        {{- $icon | safeHTML -}}
                    </a>
                </div>
            {{ end }}

            {{ if .Site.Params.shareOnTelegram }}
                {{ $icon := (replace .Site.Data.SVG.telegram "icon" "icon telegram-icon") }}
                <div class="share-item telegram">
                    {{ $url := (printf `https://t.me/share/url?url=%s&text=%s` .Permalink .Title) }}
                    <a href="{{ $url | safeURL }}" title="{{ i18n "shareOnTitle" }}{{ i18n "telegram" }}" target="_blank" rel="noopener">
                        {{- $icon | safeHTML -}}
                    </a>
                </div>
            {{ end }}

            {{ if .Site.Params.shareOnWeibo }}
                {{ $icon := (replace .Site.Data.SVG.weibo "icon" "icon weibo-icon") }}
                <div class="share-item weibo">
                    {{ $url := (printf `https://service.weibo.com/share/share.php?&url=%s&title=%s&pic=%s&searchPic=false` .Permalink .Title $images) }}
                    <a href="{{ $url | safeURL }}" title="{{ i18n "shareOnTitle" }}{{ i18n "weibo" }}" target="_blank" rel="noopener">
                        {{- $icon | safeHTML -}}
                    </a>
                </div>
            {{ end }}

            {{ if .Site.Params.shareOnDouban }}
                {{ $icon := (replace .Site.Data.SVG.douban "icon" "icon douban-icon") }}
                <div class="share-item douban">
                    {{ $url := (printf `https://www.douban.com/share/service?href=%s&name=%s&text=%s` .Permalink .Title $description) }}
                    <a href="{{ $url | safeURL }}" title="{{ i18n "shareOnTitle" }}{{ i18n "douban" }}" target="_blank" rel="noopener">
                        {{- $icon | safeHTML -}}
                    </a>
                </div>
            {{ end }}

            {{ if .Site.Params.shareOnQQ }}
                {{ $icon := (replace .Site.Data.SVG.qq "icon" "icon qq-icon") }}
                <div class="share-item qq">
                    {{ $url := (printf `https://connect.qq.com/widget/shareqq/index.html?url=%s&title=%s&summary=%s&pics=%s&site=%s` .Permalink .Title $description $images .Site.Title) }}
                    <a href="{{ $url | safeURL }}" title="{{ i18n "shareOnTitle" }}{{ i18n "qq" }}" target="_blank" rel="noopener">
                        {{- $icon | safeHTML -}}
                    </a>
                </div>
            {{ end }}

            {{ if .Site.Params.shareOnQzone }}
                {{ $icon := (replace .Site.Data.SVG.qzone "icon" "icon qzone-icon") }}
                <div class="share-item qzone">
                    {{ $url := (printf `https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=%s&title=%s&summary=%s&pics=%s&site=%s` .Permalink .Title $description $images .Site.Title) }}
                    <a href="{{ $url | safeURL }}" title="{{ i18n "shareOnTitle" }}{{ i18n "qzone" }}" target="_blank" rel="noopener">
                        {{- $icon | safeHTML -}}
                    </a>
                </div>
            {{ end }}

            {{ if .Site.Params.shareViaQRCode }}
                {{ $icon := (replace .Site.Data.SVG.qrcode "icon" "icon qrcode-icon") }}
                <div class="share-item qrcode">
                    <div class="qrcode-container" title="{{ i18n "shareViaTitle" }}{{ i18n "qrcode" }}">
                        {{- $icon | safeHTML -}}
                        <div id="qrcode-img"></div>
                    </div>
                    {{ partial "third-party/qrcode-generator.html" . }}
                </div>
            {{ end }}

        </div>

    </div>

{{ end }}
